﻿@using BXJG.Utils.Application.Share.Dtos
@using Microsoft.AspNetCore.Components.Sections
@using ZLJ.Admin.CoreRCL.Share
@using ZLJ.Application.Share.Post
@inherits DetailUpdateBaseComponent< PostDto, int,  PostEditDto>
<SectionContent SectionName=@(FuncName + "-detail-update-title")>
    <Icon Type=@detailUpdateIcon Theme=@IconThemeType.Outline />
    @(detailUpdateText)@(FuncName)
</SectionContent>
<SectionContent SectionName=@(FuncName + "-detail-update-body")>


    <Form @ref="frm" ValidateOnChange="true" Model="editDto" LabelColSpan="3" WrapperColSpan="21" OnFinish="OnFinish">

        <Row Gutter="0">
            <Col Span="24">
            <FormItem Label="名称">
                @if (IsShowUpdate)
                {
                    <Input @bind-Value="@context.DisplayName" AllowClear />
                }
                else
                {
                    <span class="frm-field-readonly">
                        @dto.DisplayName
                    </span>
                }
            </FormItem>
            </Col>
        </Row>
        <Row Gutter="0">
            <Col Span="8">
            <FormItem LabelColSpan="9" WrapperColSpan="15">
                @if (IsShowUpdate)
                {
                    <Checkbox @bind-Value="@context.IsDefault" />
                }
                else
                {
                    <Checkbox @bind-Value="@dto.IsDefault" Disabled />
                }
            </FormItem>
            </Col>
            <Col Span="8">
            <FormItem LabelColSpan="9" WrapperColSpan="15">
              @*   @if (IsShowUpdate)
                {
                    <Checkbox @bind-Value="@context.IsStatic" />
                }
                else
                { *@
                    <Checkbox @bind-Value="@dto.IsStatic" Disabled />
                @* } *@
            </FormItem>
            </Col>
            <Col Span="8">
            <FormItem LabelColSpan="9" WrapperColSpan="15">
                @if (IsShowUpdate)
                {
                    <Checkbox @bind-Value="@context.IsAttention" />
                }
                else
                {
                    <Checkbox @bind-Value="@dto.IsAttention" Disabled />
                }
            </FormItem>
            </Col>
        </Row>
        <Row Gutter="0">
            <Col Span="24">
            <FormItem Label="备注">
                @if (IsShowUpdate)
                {
                    <Input @bind-Value="@context.Description" AllowClear />
                }
                else
                {
                    <span class="frm-field-readonly">
                        @dto.DisplayName
                    </span>
                }
            </FormItem>   </Col>
        </Row>
        <Row Gutter="0">
            <Col Span="24">
            <FormItem Label="权限">


                @if (IsShowUpdate)
                {
                    <TreePermission KeyExpression="x => x.DataItem.Name" Style="height:50vh; overflow-y:auto;" DefaultExpandParent @bind-CheckedKeys="@editDto.GrantedPermissions" />
                }
                else
                {
                    <TreePermission KeyExpression="x=>x.DataItem.Name" Disabled  DisabledExpression="x=>true"  Style="height:50vh; overflow-y:auto;" DefaultExpandParent @bind-CheckedKeys="@dto.GrantedPermissions" />
                }



            </FormItem>
            </Col>
        </Row>

    </Form>



</SectionContent>
<SectionContent SectionName=@(FuncName + "-detail-update-btns")>
    @if (IsShowDelete)
    {
        <Popconfirm Title="确定删除此项吗?" OnConfirm=BtnDeleteClick>
            <Button Loading=isDeleting Danger=true>删除</Button>
        </Popconfirm>
    }
    <ButtonGroup>
        @if (IsShowRefresh)
        {
            <Button OnClick="BtnRefreshClick" Loading=isRefreshing Disabled="IsBusy">刷新</Button>
        }
        @if (IsShowBeginEdit)
        {
            <Button OnClick="BtnBeginEditClick" Loading=isFormIniting Type="@ButtonType.Primary">修改</Button>
        }
        else if (IsShowUpdate)
        {
            <Button OnClick="BtnResetClick" Loading=isReseting Disabled="IsBusy" Icon="@IconType.Outline.Redo">重置</Button>
            <Button OnClick="BtnCancelEditClick" Disabled="IsBusy" Icon="@IconType.Outline.Rollback">放弃修改</Button>
            <Button OnClick="BtnUpdateClick" Type="@ButtonType.Primary" Loading="@isUpdating" Disabled="IsBusy" Icon="@IconType.Outline.Save">保存</Button>
        }
    </ButtonGroup>
</SectionContent>